package ru.gitverse.deenyy.walp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ru.gitverse.deenyy.walp.model.*;
import ru.gitverse.deenyy.walp.service.CalculationBatchService;

import java.util.List;

@RestController
@RequestMapping("/angles")
public class AngleController {

    @Autowired
    private CalculationBatchService calculationBatchService;

    @PostMapping("/batch")
    public CalculationBatch createBatch(@RequestBody BatchRequest batchRequest) {
        return calculationBatchService.createCalculationBatch(batchRequest.getName(), batchRequest.getAngleRequests());
    }

    @PostMapping("/batch/{batchId}/calculate")
    public CalculationBatch calculateGammaForBatch(@PathVariable Long batchId) {
        return calculationBatchService.calculateAndSaveGammaForBatch(batchId);
    }
}
